
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <title>Lisp interpreter in Javascript</title>
    <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/3.4.1/build/cssreset/cssreset-min.css">
    <link rel="stylesheet" href="base.css" type="text/css" media="screen" />
    <meta name="description" content="Lisp interpreter written in javascript" />
  </head>
  <body>
    <!-- page content -->
    <div class="content">
      <h1>Lisp interpreter in Javascript</h1>
      <div class="repl">
	<textarea name="" id="history" rows="10" cols="80" tabindex=""></textarea>
	<textarea name="" id="input" rows="3" cols="80" tabindex=""></textarea>
	<button class="" id="evaluate">Evaluate</button>
      </div>
      <div class="keywords">
	<h2>Keywords</h2>
	<pre>
	  car cdr cons
	  not and or
	  &gt;= &gt; &lt;= &lt; = eq
	  + - * /
	  nil list setq if lambda defun
	</pre>
      </div>
      <div class="examples">
	<h2>Examples</h2>
	<pre>
	  Factorial

	  (defun fact (x) (if (&lt;= x 1) 1 (* x (fact (- x 1)))))
	  (fact 5)

	  Reverse a list

	  (defun reverse- (x r)
	  (if (not (car x)) r (reverse- (cdr x) (cons (car x) r))))
	  (defun reverse (x) (reverse- x (list)))
	  (reverse (list 1 2 3 4))

	  Map a list

	  (defun mapcar (x f)
	  (if (not (car x)) (list) (cons (f (car x)) (mapcar (cdr x) f))))
	  (mapcar (list 1 2 3) (lambda (x) (* x x)))
	</pre>
      </div>
    </div>

    <!-- javascrpit -->
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
    <script type="text/javascript" src="lisp.js"></script>
    <script type="text/javascript">
      $(init);
    </script>
  </body>
</html>
